import axios from 'axios'

//引入加载进度条
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

const http =axios.create({
  baseURL:'http://127.0.0.1:8888/api/private/v1/'
})

http.interceptors.request.use(config=>{
   //请求拦截每次发次请求时授权挂载一个token令牌
  config.headers.Authorization=window.sessionStorage.getItem('token')
  //显示进度条
  NProgress.start();
  return config
})
//响应拦截器
http.interceptors.response.use(config=>{
  //隐藏进度条
  NProgress.done();
  return config
})

export default http
